<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">优惠券管理</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <div class="am-form-group">
                            <?php if (checkPrivilege('/couponadd')): ?>
                                <div class="am-btn-group am-btn-group-xs">
                                    <a class="am-btn am-btn-default am-btn-success"
                                       href="<?= url('couponadd') ?>">
                                        <span class="am-icon-plus"></span> 新增
                                    </a>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="">

                        </form>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>优惠券ID</th>
                                <th>优惠券名称</th>
                                <th>商铺名称</th>
                                <th>优惠券颜色</th>
                                <th>是否为虚拟优惠券</th>
                                <th>优惠券类型</th>
                                <th>到期类型</th>
                                <th>起始时间</th>
                                <th>截至时间</th>
                                <th>适用范围</th>
                                <th>承担模式</th>
                                <th>添加时间</th>
                                <th>编辑时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle"><?= $item['coupon_id'] ?></td>
                                    <td class="am-text-middle"><?= $item['name'] ?></td>
                                    <td class="am-text-middle"><?= $item['shop_name'] ?></td>
                                    <td class="am-text-middle">
                                        <?=$item['color_text']?>
                                    </td>
                                    <td class="am-text-middle">
                                        <?=$item['lq_type_text']?>
                                    </td>
                                    <td class="am-text-middle">
                                        <?=$item['coupon_type_text']?>
                                    </td>
                                    <td class="am-text-middle">
                                        <?=$item['expire_type_text']?>
                                    </td>
                                    <td class="am-text-middle"><?= $item['start_time_text'] ?></td>
                                    <td class="am-text-middle"><?= $item['end_time_text'] ?></td>
                                    <td class="am-text-middle">
                                        <?=$item['apply_range_text']?>
                                    </td>
                                    <td class="am-text-middle"><?=$item['bear_type_text']?></td>
                                    <td class="am-text-middle"><?=$item['create_time_text']?></td>
                                    <td class="am-text-middle"><?=$item['update_time_text']?></td>
                                    <td class="am-text-middle">
                                        <?php if (checkPrivilege('couponedit')): ?>

                                            <a class="tpl-table-black-operation-default"

                                               href="<?= url('couponedit', ['id' => $item['coupon_id']]) ?>">

                                                <i class="am-icon-pencil"></i> 编辑

                                            </a>

                                        <?php endif; ?>
                                        <?php if (checkPrivilege('coupondelete')): ?>

                                            <a class="j-delete tpl-table-black-operation-default"

                                               href="javascript:void(0);" data-id="<?= $item['coupon_id'] ?>">

                                                <i class="am-icon-trash"></i> 删除

                                            </a>

                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="12" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?> </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>

    $(function () {

        // 删除元素
        var url = "<?= url('coupondelete') ?>";

        $('.j-delete').delete('id', url);

    });

</script>

